//
//  MyImageView.m
//  YunGui
//
//  Created by Hanen 3G 01 on 16/4/22.
//  Copyright © 2016年 hanen. All rights reserved.
//

#import "MyImageView.h"

@implementation MyImageView


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubviews];
        self.opaque = YES;
        self.contentMode = UIViewContentModeScaleAspectFit;
        self.userInteractionEnabled = YES;
        self.isSelfSelected = NO;
    }
    return self;
}
- (void)addSubviews
{
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(self.width - 50, 10, 40, 40)];
    [btn setBackgroundImage:[UIImage imageNamed:@"shanchu.png"] forState:UIControlStateNormal];
//    btn.backgroundColor = [UIColor orangeColor];
    [self addSubview:btn];
    [btn addTarget:self action:@selector(searchBarCancelButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)searchBarCancelButtonClicked:(UIButton *)btn
{
    self.isSelfSelected = YES;
//    if (btn.selected == NO) {
        if (self.block) {
            self.block(self,self.isSelfSelected);
           
//        }
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
